import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Card } from 'antd';
import moment from 'moment';
import DescriptionList from '@/components/DescriptionList';

const { Description } = DescriptionList;
@connect(({ integratedquery, loading }) => ({
  loading: loading.models.integratedquery,
  empLaborContInfoList: integratedquery.empLaborContInfoList, // 劳动合同信息数据
}))
@Form.create()
class EmpInfor extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {}

  jumpRouting = (targetRouter, laborContId) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, laborContId);
  };

  render() {
    const { empLaborContInfoList } = this.props;
    // 判断是否为空对象
    const isEmptyObj = obj => {
      if (obj) {
        return JSON.stringify(obj) === '{}';
      }
      return false;
    };
    return (
      <div>
        <Card
          style={{ marginBottom: 12 }}
          title={<span style={{ fontWeight: 'bolder' }}>劳动合同信息</span>}
          bordered={false}
          extra={
            !empLaborContInfoList || isEmptyObj(empLaborContInfoList) ? null : (
              <a
                onClick={() =>
                  this.jumpRouting(
                    'laborContId',
                    empLaborContInfoList && empLaborContInfoList.laborContId
                  )
                }
              >
                详情&gt;&gt;
              </a>
            )
          }
          id="laborcontractinfor"
        >
          {!empLaborContInfoList || isEmptyObj(empLaborContInfoList) ? (
            <p>暂无数据</p>
          ) : (
            <DescriptionList>
              <Description term="客户名称">
                {(empLaborContInfoList && empLaborContInfoList.custName) || '--'}
              </Description>
              <Description term="合同编号">
                {(empLaborContInfoList && empLaborContInfoList.contNo) || '--'}
              </Description>
              <Description term="合同开始日期">
                {empLaborContInfoList && empLaborContInfoList.contBeginDate
                  ? moment(empLaborContInfoList.contBeginDate).format('YYYY-MM-DD')
                  : '--'}
              </Description>
              <Description term="合同结束日期">
                {empLaborContInfoList && empLaborContInfoList.contEndDate
                  ? moment(empLaborContInfoList.contEndDate).format('YYYY-MM-DD')
                  : '--'}
              </Description>
              <Description term="合同状态">
                {(empLaborContInfoList && empLaborContInfoList.contStateName) || '--'}
              </Description>
              <Description term="签订类型">
                {(empLaborContInfoList && empLaborContInfoList.signTypeName) || '--'}
              </Description>
              <Description term="合同签署方式">
                {(empLaborContInfoList && empLaborContInfoList.contSignWayName) || '--'}
              </Description>
              <Description term="签订日期">
                {empLaborContInfoList && empLaborContInfoList.signDate
                  ? moment(empLaborContInfoList.signDate).format('YYYY-MM-DD')
                  : '--'}
              </Description>
            </DescriptionList>
          )}
        </Card>
      </div>
    );
  }
}

export default EmpInfor;
